package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PenaltyHistory;
import com.pgybook.db.entity.domain.PenaltyHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PenaltyHistoryMapper {
    int countByExample(PenaltyHistoryEx example);

    int deleteByExample(PenaltyHistoryEx example);

    @Delete({
            "delete from penaltyhistory",
            "where PENALTYHISID = #{penaltyhisid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long penaltyhisid);

    @Insert({
            "insert into penaltyhistory (INSTANCEID, CUSTID, ",
            "PENALTYTYPE, PENALAMT, ",
            "BORWSTARTTIME, BORWENDTIME, ",
            "EXCEEDDAYS, HANDLETYPE, ",
            "HANDLERESULT, REMARK, ",
            "CRTTIME, HANDLESTAFF, ",
            "STATUS)",
            "values (#{instanceid,jdbcType=BIGINT}, #{custid,jdbcType=BIGINT}, ",
            "#{penaltytype,jdbcType=INTEGER}, #{penalamt,jdbcType=DECIMAL}, ",
            "#{borwstarttime,jdbcType=TIMESTAMP}, #{borwendtime,jdbcType=TIMESTAMP}, ",
            "#{exceeddays,jdbcType=INTEGER}, #{handletype,jdbcType=INTEGER}, ",
            "#{handleresult,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{handlestaff,jdbcType=INTEGER}, ",
            "#{status,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "penaltyhisid", before = false, resultType = Long.class)
    int insert(PenaltyHistory record);

    int insertSelective(PenaltyHistory record);

    List<PenaltyHistory> selectByExample(PenaltyHistoryEx example);

    @Select({
            "select",
            "PENALTYHISID, INSTANCEID, CUSTID, PENALTYTYPE, PENALAMT, BORWSTARTTIME, BORWENDTIME, ",
            "EXCEEDDAYS, HANDLETYPE, HANDLERESULT, REMARK, CRTTIME, HANDLESTAFF, STATUS",
            "from penaltyhistory",
            "where PENALTYHISID = #{penaltyhisid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    PenaltyHistory selectByPrimaryKey(Long penaltyhisid);

    int updateByExampleSelective(@Param("record") PenaltyHistory record, @Param("example") PenaltyHistoryEx example);

    int updateByExample(@Param("record") PenaltyHistory record, @Param("example") PenaltyHistoryEx example);

    int updateByPrimaryKeySelective(PenaltyHistory record);

    @Update({
            "update penaltyhistory",
            "set INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "PENALTYTYPE = #{penaltytype,jdbcType=INTEGER},",
            "PENALAMT = #{penalamt,jdbcType=DECIMAL},",
            "BORWSTARTTIME = #{borwstarttime,jdbcType=TIMESTAMP},",
            "BORWENDTIME = #{borwendtime,jdbcType=TIMESTAMP},",
            "EXCEEDDAYS = #{exceeddays,jdbcType=INTEGER},",
            "HANDLETYPE = #{handletype,jdbcType=INTEGER},",
            "HANDLERESULT = #{handleresult,jdbcType=INTEGER},",
            "REMARK = #{remark,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "HANDLESTAFF = #{handlestaff,jdbcType=INTEGER},",
            "STATUS = #{status,jdbcType=INTEGER}",
            "where PENALTYHISID = #{penaltyhisid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PenaltyHistory record);
}
